<%@ page import="com.scalar.chiptrack.commons.Constants,
                 com.scalar.chiptrack.operations.process.ProcessTypes,
                 org.apache.struts.util.LabelValueBean,
                 java.util.ArrayList"%>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager" %>
<%@ page import="com.scalar.chiptrack.users.Functionality" %>
<%@ page import="com.scalar.chiptrack.users.User" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/purchaseOrders.do"/>

<%
    int i = 0;
    String chipTracContext = "/" + ConfigManager.getChipTracContext();
    String functionalityString = Functionality.PURCHASE_ORDER;
 
%>

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet">
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<script language="javascript">

<%
	com.scalar.chiptrack.finance.openpo.forms.PurchaseOrderForm purchaseForm = (com.scalar.chiptrack.finance.openpo.forms.PurchaseOrderForm)session.getAttribute( "purchaseOrderForm" );
	ArrayList addressList = purchaseForm.getFormattedShippingAddressList();
%>
    var shipAddress       = new Array(<%=addressList.size()%>);
<%
	for( int l = 0; l < addressList.size(); l++ )
    {
%>
	shipAddress[ <%=l%> ] = '<%=((String)addressList.get(l)).replace('\n','~').replaceAll("'","\\\\" + "'")%>';
<%
	}
%>

function loadShippingAddress()
{
	document.purchaseOrderForm.shippingAddressAsString.value = shipAddress[document.purchaseOrderForm.contactPerson.selectedIndex].replace(/~/g,'\n');
}

window.onload = init;
var errors = '';
var errorIndex;
var prevPrice = 0.0;
var lineItemsComments = new Array();

var dateElement = "";
function openCalendar(dateValue)
{
    dateElement = dateValue;
    newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
    newWindow.moveTo(550,180);
    newWindow.focus();
}

function assignDate(passedValue)
{
    dateElement.value=passedValue;
    window.focus();
}

function loadComments( idx )
{
    var selectedIdx = document.purchaseOrderForm['purchaseOrderLineItemList[' + idx + '].processStepId'].selectedIndex;
	document.purchaseOrderForm['purchaseOrderLineItemList[' + idx + '].customerPartNumber'].value='';
    if( selectedIdx > 0 )
    {
		if( lineItemsComments[idx][selectedIdx-1] != null )
		{
			document.purchaseOrderForm['purchaseOrderLineItemList[' + idx + '].description'].value = lineItemsComments[idx][selectedIdx-1];
		}
    }
    else
    {
        document.purchaseOrderForm['purchaseOrderLineItemList[' + idx + '].description'].value='';
    }
    calculateTotals();
}

function loadPartNumbers( index )
{
    document.purchaseOrderForm.purchaseOrderNumber.disabled=false;
    document.purchaseOrderForm.poType.disabled=false;
    document.purchaseOrderForm.vendorName.disabled=false;
    document.purchaseOrderForm.purchaseOrderDate.disabled=false;

    var lineItemCount = !document.purchaseOrderForm.lineItem.length ? 0 : document.purchaseOrderForm.lineItem.length-1;
    for ( var i = 0; i <= lineItemCount; i++ )
    {
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].previouslyShipppedQty'].disabled = false;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].shippedQty'].disabled = false;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].extendedCost'].disabled = false;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].packageType'].disabled = false;;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].requestedDate'].disabled = false;;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].promisedDate'].disabled = false;;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].requestedQuantity'].disabled = false;;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].unitCost'].disabled = false;;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].cancel'].disabled = false;
    }

    document.purchaseOrderForm['subTotal'].disabled = false;
    document.purchaseOrderForm['total'].disabled = false;
    document.purchaseOrderForm['tax'].disabled = false;

    document.purchaseOrderForm.action='<%=chipTracContext%>/purchaseOrders.do?action=loadPartNumbers&lineItemIndex=' + index+ '&refresh=0' ;
    document.purchaseOrderForm.submit();
}

function refreshPO( index )
{
    document.purchaseOrderForm.purchaseOrderNumber.disabled=false;
    document.purchaseOrderForm.poType.disabled=false;
    document.purchaseOrderForm.vendorName.disabled=false;
    document.purchaseOrderForm.purchaseOrderDate.disabled=false;

    var lineItemCount = !document.purchaseOrderForm.lineItem.length ? 0 : document.purchaseOrderForm.lineItem.length-1;
    for ( var i = 0; i <= lineItemCount; i++ )
    {
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].previouslyShipppedQty'].disabled = false;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].shippedQty'].disabled = false;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].extendedCost'].disabled = false;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].packageType'].disabled = false;
        if( document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].packageType'].value == 'Add_New_Package')
        {
            document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].packageType'].value='';
        }
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].requestedDate'].disabled = false;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].promisedDate'].disabled = false;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].requestedQuantity'].disabled = false;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].unitCost'].disabled = false;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].cancel'].disabled = false;
    }

    document.purchaseOrderForm['subTotal'].disabled = false;
    document.purchaseOrderForm['total'].disabled = false;
    document.purchaseOrderForm['tax'].disabled = false;

    document.purchaseOrderForm.action='<%=chipTracContext%>/purchaseOrders.do?action=loadPartNumbers&lineItemIndex=' + index + '&refresh=1' ;
    document.purchaseOrderForm.submit();
}

function addLineItem()
{
    document.purchaseOrderForm.purchaseOrderNumber.disabled=false;
    var lineItemCount = !document.purchaseOrderForm.lineItem.length ? 0 : document.purchaseOrderForm.lineItem.length-1;
    for ( var i = 0; i <= lineItemCount; i++ )
    {
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].previouslyShipppedQty'].disabled = false;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].shippedQty'].disabled = false;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].extendedCost'].disabled = false;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].packageType'].disabled = false;;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].requestedDate'].disabled = false;;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].promisedDate'].disabled = false;;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].requestedQuantity'].disabled = false;;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].unitCost'].disabled = false;;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].cancel'].disabled = false;
    }

    document.purchaseOrderForm['subTotal'].disabled = false;
    document.purchaseOrderForm['total'].disabled = false;
    document.purchaseOrderForm['tax'].disabled = false;

    document.purchaseOrderForm.action='<%=chipTracContext%>/purchaseOrders.do?action=addLineItem' ;
    document.purchaseOrderForm.submit();
}

function confirmPO()
{
    errors = '';
    var tmpErrMsg = '';
    var lineItemCount = !document.purchaseOrderForm.lineItem.length ? 0 : document.purchaseOrderForm.lineItem.length-1;
    var validLineItemsCount = false;
    var poDate = document.purchaseOrderForm.purchaseOrderDate.value;
    var validToDate = document.purchaseOrderForm.validToDate.value;
    var commentsLength = document.purchaseOrderForm.comments.value.length;
    var shippingMethodIdCtrl = document.purchaseOrderForm.shippingMethodId;
    var payTermsCtrl = document.purchaseOrderForm.payTerms;
    var poErrors = document.getElementById( "poErrors" );
    poErrors.innerHTML = "";
    <logic:lessEqual value="0" property="purchaseOrder_Id"  name="purchaseOrderForm" >
    var poNumberCtrl = document.purchaseOrderForm['purchaseOrderNumber'];
    if (poNumberCtrl.value.trim() == '')
    {
        poNumberCtrl.focus();
        poErrors.innerHTML += "<li> Please enter PO Number";
    }
    else
    {
        if (chkSalesOrderNoBegin(poNumberCtrl.value.trim()))
        {
            poNumberCtrl.focus();
            poErrors.innerHTML += "<li>PO Number should not start with special characters ";
        }
        else
            if (! chkSalesOrderNo(poNumberCtrl.value.trim()))
            {
                poNumberCtrl.focus();
                poErrors.innerHTML += "<li>Please enter valid PO Number";
            }
    }
    </logic:lessEqual>
    if ( shippingMethodIdCtrl.value == -1 )
    {
        poErrors.innerHTML += "<li> Please select <bean:message key="label.sales.salesOrder.ShippingMethod" />";
    }
    else if ( shippingMethodIdCtrl.value == -2 )
    {
        if ( document.purchaseOrderForm.newShippingMethod.value.trim().length == 0 )
        {
            poErrors.innerHTML += "<li> Please enter New Shipping Method";
        }
        if ( document.purchaseOrderForm.newShippingAccount.value.trim().length == 0 )
        {
            poErrors.innerHTML += "<li> Please enter New Shipping Account";
        }
    }
    if ( payTermsCtrl.value == -1 )
    {
        poErrors.innerHTML += "<li> Please select Pay Terms";
    }
    else if ( payTermsCtrl.value == -2 )
    {
        if ( document.purchaseOrderForm.newPayTerms.value.trim().length == 0 )
        {
            poErrors.innerHTML += "<li> Please enter New Pay Terms";
        }
    }
    if ( poErrors.innerHTML != "" )
    {
        poErrors.focus();
        return;
    }
    if( commentsLength > 200 )
    {
        errorIndex.innerHTML = "<li> Comments Should be Maximum of 200 Characters";
        errorIndex.focus();
        return;
    }
    if ( chkDate( validToDate, "Valid-To date", "Y") == false )
    {
        poErrors.innerHTML = errMsg;
        poErrors.focus();
        return;
    }
    for ( var i = 0; i <= lineItemCount; i++ )
    {
        var processName = document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].processName'].value;
        var requestedDate = document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].requestedDate'].value;
        var requestedQty = document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].requestedQuantity'];

        if( (processName != "") ||  requestedDate != "" || (requestedQty.value != "" && requestedQty.value != "0") )
        {
            validLineItemsCount = true;
            <%--start: mandatory fields--%>
            var processStepId = document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].processStepId'].value;
            var prevShippedQty = document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].previouslyShipppedQty'].value;
            var shippedQty = document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].shippedQty'].value;
            <%--end: Mandatory fields--%>
            var promisedDate = document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].promisedDate'].value;
            var unitCost = document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].unitCost'].value;
            var freight = document.purchaseOrderForm['freight'].value;
            var tradeDiscount = document.purchaseOrderForm['tradeDiscount'];
            var misc = document.purchaseOrderForm['miscellaneous'].value;
            var tax = document.purchaseOrderForm['tax'].value;
            var total = document.purchaseOrderForm['total'];

            var descriptionLength = document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].description'].value.length;


            if ( processName == '' )
            {
                errors = errors + "<li> Please select a Process Name for LineItem "+eval(i+1)
            }
            if ( processStepId == '' && processName != '')
            {
                errors = errors + "<li> Please select a  Part Number for LineItem "+eval(i+1)
            }
            if ( chkDate( requestedDate, "Requested date","Y") == false )
            {
                errors = errors + errMsg+" for LineItem "+eval(i+1);
            }

            tmpErrMsg = checkQuantity( requestedQty, "Requested Quantity" );
            if( tmpErrMsg != '' )
            {
                errors = errors + tmpErrMsg +" for LineItem "+eval(i+1);
            }
            if( parseInt(requestedQty.value) < ( parseInt (prevShippedQty) + parseInt (shippedQty)) )
            {
                errors = errors + "<li> Requested Quantity cannot be less than the sum of Previously Received Quantity and Received Quantity for LineItem "+eval(i+1)
            }
            if ( chkDate( promisedDate, "Promised date","n") == false )
            {
                errors = errors + errMsg+" for LineItem "+eval(i+1);
            }
            /*tmpErrMsg = checkAmount(unitCost, "Unit Cost");
            if( tmpErrMsg != '' )
            {
                errors = errors + "<li> "+tmpErrMsg +" for LineItem "+eval(i+1);
            }*/
            tmpErrMsg = checkAmount(freight, "Freight Amount");
            if( tmpErrMsg != '' )
            {
                errors = errors + "<li> "+tmpErrMsg +" for LineItem "+eval(i+1);
            }
            tmpErrMsg = checkAmount(tradeDiscount.value, "Trade Discount");
            if( tmpErrMsg != '' )
            {
                errors = errors + "<li> "+tmpErrMsg +" for LineItem "+eval(i+1);
            }
            tmpErrMsg = checkAmount(misc, "Miscellaneous Amount");
            if( tmpErrMsg != '' )
            {
                errors = errors + "<li> "+tmpErrMsg +" for LineItem "+eval(i+1);
            }
            if( descriptionLength > 200 )
            {
                errors = errors + "<li> Description Should be Maximum of 200 Characters for LineItem "+eval(i+1);
            }

            if ( ( chkDate( requestedDate, "Requested date","Y") == true ) && !validateDateOut(formatDateAsMMDDYYYY(poDate),formatDateAsMMDDYYYY(requestedDate)) )
            {
                errors = errors + "<li> Requested Date cannot be less than PO Date for Line Item "+eval(i+1);
                document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].requestedDate'].focus();
            }
            if( errors != '' )
            {
                errorIndex.innerHTML = errors;
                errorIndex.focus();
                return;
            }
        }
    }
    if( validLineItemsCount == false )
    {
        errorIndex.innerHTML = "<li> Please enter valid data for atleast one Line Item</li>";
        errorIndex.focus();
        return;
    }

    for ( var i = 0; i <= lineItemCount; i++ )
    {
        var processStepIdObj    = document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].processStepId'];
        var partNumberObj       = document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].partNumber'];
        var selectedPartNumber  = processStepIdObj.options[processStepIdObj.selectedIndex].text;
        partNumberObj.value     = selectedPartNumber;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].previouslyShipppedQty'].disabled = false;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].shippedQty'].disabled = false;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].extendedCost'].disabled = false;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].packageType'].disabled = false;;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].requestedDate'].disabled = false;;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].promisedDate'].disabled = false;;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].requestedQuantity'].disabled = false;;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].unitCost'].disabled = false;;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].cancel'].disabled = false;

        if( document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].packageType'].value == "Add_New_Package" )
        {
            errorIndex.innerHTML = "<li> Please Close Add New Package Window</li>";
            errorIndex.focus();
            return;
        }
    }

    var newState = document.purchaseOrderForm.newPOState;
    var newTax   = document.purchaseOrderForm.newPOTax;

    if( ( typeof newState !='undefined' ) && ( typeof newTax !='undefined' ) )
    {
        if( ( document.purchaseOrderForm.newPOState.value == '' ) && ( document.purchaseOrderForm.newPOTax.value == '' ) )
        {
            errorIndex.innerHTML = "<li> Please enter valid State and Tax </li>";
            errorIndex.focus();
            return;
        }
        if( ( document.purchaseOrderForm.newPOState.value != '' ) && ( document.purchaseOrderForm.newPOTax.value == '' ) )
        {
            errorIndex.innerHTML = "<li> Please enter valid Tax </li>";
            errorIndex.focus();
            return;
        }
        if( ( document.purchaseOrderForm.newPOState.value == '' ) && ( document.purchaseOrderForm.newPOTax.value != '' ) )
        {
            errorIndex.innerHTML = "<li> Please enter State </li>";
            errorIndex.focus();
            return;
        }
        if( ( document.purchaseOrderForm.newPOState.value != '' ) && ( document.purchaseOrderForm.newPOTax.value <= 0.00 ) )
        {
            errorIndex.innerHTML = "<li> New Tax Should be greater than Zero (0) </li>";
            errorIndex.focus();
            return;
        }

    }

    calculateTotals();

    document.purchaseOrderForm['subTotal'].disabled = false;
    document.purchaseOrderForm['total'].disabled = false;
    document.purchaseOrderForm['tax'].disabled = false;

    document.purchaseOrderForm.poType.disabled = false;
    document.purchaseOrderForm.poTypeLabel.value = document.purchaseOrderForm.poType.options[document.purchaseOrderForm.poType.selectedIndex].text;

    document.purchaseOrderForm.purchaseOrderNumber.disabled=false;
    document.purchaseOrderForm.action='<%=chipTracContext%>/purchaseOrders.do?action=confirm' ;
    document.purchaseOrderForm.submit();
}

function checkAmount(fieldValue,fieldName )
{
    if ( (checkFloat( fieldValue, fieldName, 'n' ) == false) )
    {
        return errMsg;
    }
    if(check_char_position4(fieldValue) || (is_Sp_Characters_frieght(fieldValue) == false)  )
    {
        return "Please enter a valid "+fieldName;
    }
    if( fieldValue.length >= 8 )
    {
        var index = fieldValue.indexOf(".");
        if( index == -1 || index > 7 )
        {
            return "Please enter a valid "+fieldName+" (amount should be in XXXXXXX.XX format)";
        }
    }
    return '';
}


function checkQuantity(qty,name)
{
   if(!isInteger(qty.value))
    {
        return "<li>  Please enter a valid "+name;
    }
    else if(qty.value == 0)
    {
        return "<li>  Please enter a valid "+name;
    }
    else if((qty.value).length > 6)
    {
        return "<li>  Please enter a valid "+name+" (should not allow more than 6 digits)";
    }
    return '';
}
<%--the following functions don't need client-side validations--%>



function lotDateEntry( purchaseOrderLineItemNumber )
{
    errors='';
    var partNo = document.purchaseOrderForm['purchaseOrderLineItemList[' + eval(purchaseOrderLineItemNumber-1) + '].processStepId'].value
    if( partNo != '' )
    {
        var finHold = document.purchaseOrderForm['purchaseOrderLineItemList[' + eval(purchaseOrderLineItemNumber-1) + '].financeHold'].value;
        var opsHold = document.purchaseOrderForm['purchaseOrderLineItemList[' + eval(purchaseOrderLineItemNumber-1) + '].operationsHold'].value;

        if( finHold != '0' || opsHold != '0')
        {
            errors = "<li> Please approve the LineItem to pull the quantity"
            errorIndex.innerHTML = errors;
            errorIndex.focus();
            return;
        }
        errorIndex.innerHTML = "";
        newWindow = window.open ('<%=chipTracContext%>/purchaseOrders.do?action=purchaseOrderLineItemLotEntry&purchaseOrderLineItemNumber='+purchaseOrderLineItemNumber,'optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=700,height=300,resizable=yes,screenX=5,screenY=55,left=50,top=40');
        newWindow.focus();
    }
    else
    {
        errors = "<li> Please select a Part Number before pulling the quantity for LineItem "+  purchaseOrderLineItemNumber
        errorIndex.innerHTML = errors;
        errorIndex.focus();
        return;
    }
}

function disableHolds( idx, disable )
{
    if( disable == true )
    {
        document.purchaseOrderForm['purchaseOrderLineItemList[' + idx + '].financeHold'].disabled = true;
        document.purchaseOrderForm['purchaseOrderLineItemList[' + idx + '].operationsHold'].disabled = true;
    }
}

function openAuditTrail( purchaseOrder_Id, poNumber )
{
    newWindow=window.open('<%=chipTracContext%>/openPurchaseOrder.do?action=auditTrail&purchaseOrder_id='+purchaseOrder_Id+'&poNumber='+poNumber,'auditTrailPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=600,height=700,left=100,top=50,resizable=yes');
    newWindow.moveTo(100,50);
    newWindow.focus();
}

function openReasonCodes()
{
    newWindow = window.open('<%=chipTracContext%>/reasonCodes.do?action=Show','reasonCodesPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,top=0,left=0,height=300,widht=500,resizable=yes');
    newWindow.focus();
}

function init()
{
    errorIndex = document.getElementById("errorIndex");
    showHideNewShippingMethod();
    showHideNewPayTerms();
    var lineItemCount = !document.purchaseOrderForm.lineItem.length ? 0 : document.purchaseOrderForm.lineItem.length-1;

    document.purchaseOrderForm['purchaseOrderLineItemList[' + lineItemCount + '].status'].tabIndex = -1;
    document.purchaseOrderForm['purchaseOrderLineItemList[' + lineItemCount + '].cancel'].tabIndex = -1;
    document.purchaseOrderForm['purchaseOrderLineItemList[' + lineItemCount + '].financeHold'].tabIndex = -1;
    document.purchaseOrderForm['purchaseOrderLineItemList[' + lineItemCount + '].operationsHold'].tabIndex = -1;

    for( var i=0; i<lineItemCount; i++)
    {
        if( document.purchaseOrderForm['purchaseOrderLineItemList[' + lineItemCount + '].shippedQty'].value != '0' )
        {
            document.purchaseOrderForm['purchaseOrderLineItemList[' + lineItemCount + '].financeHold'].disabled = true;
            document.purchaseOrderForm['purchaseOrderLineItemList[' + lineItemCount + '].operationsHold'].disabled = true;
        }
    }
    var poTaxType = document.purchaseOrderForm.poTaxType;
     <%

         String state = request.getParameter ( "newPOState" );
         String value = request.getParameter ( "newPOTax" );
         if( state != null && value != null )
         {
     %>
             if( typeof poTaxType !='undefined' )
             {
                 if ( poTaxType.value == "-1" )
                 {
                     addNewPOTaxType( document.purchaseOrderForm.poTaxType );
                     document.purchaseOrderForm.newPOState.value = '<%=state%>';
                     document.purchaseOrderForm.newPOTax.value = '<%=value%>';
                 }
             }
     <%  }  %>

     //do not remove the following line
     calculateTotals();
}

function calculateTotals()
{
    errorIndex.innerHTML = "";
    var lineItemCount = !document.purchaseOrderForm.lineItem.length ? 0 : document.purchaseOrderForm.lineItem.length-1;
    var subTotal = 0.00;
    var freight = document.purchaseOrderForm['freight'];
    var stateWithtaxType = "0"
    var taxVal = '0.0'

    if( freight.value == '' )
    {
        errors = "<li> Please enter valid Freight"
        errorIndex.innerHTML = errors;
        errorIndex.focus();
        return;
    }
    var tradeDiscount = document.purchaseOrderForm['tradeDiscount'];
    if( tradeDiscount.value == '' )
    {
        errors = "<li> Please enter valid Trade Discount"
        errorIndex.innerHTML = errors;
        errorIndex.focus();
        return;
    }
    var misc = document.purchaseOrderForm['miscellaneous'];
    if( misc.value == '' )
    {
        errors = "<li> Please enter valid Miscellaneous"
        errorIndex.innerHTML = errors;
        errorIndex.focus();
        return;
    }
    var tax = document.purchaseOrderForm['tax'];
    if( tax.value == '' )
    {
        errors = "<li> Please enter valid Tax"
        errorIndex.innerHTML = errors;
        errorIndex.focus();
        return;
    }
    var total = document.purchaseOrderForm['total'];
    for ( var i=0; i<=lineItemCount; i++)
    {
        var partNo = document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].processStepId'].value
        var status = document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].status'].value
        if( partNo != '' && status != 'Cancelled')
        {
            var extendedCost = document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].extendedCost'];
            var requestedQuantity = document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].requestedQuantity'].value.trim();
            if( requestedQuantity == '' )
            {
                errors = "<li> Please enter valid Requested Quantity"
                errorIndex.innerHTML = errors;
                errorIndex.focus();
                return;
            }
            var unitCost =  document.purchaseOrderForm['purchaseOrderLineItemList[' + i + '].unitCost'] ;
            if( unitCost.value == '' )
            {
                errors = "<li> Please enter valid Unit Cost for LineItem "+ eval( i+1)
                errorIndex.innerHTML = errors;
                errorIndex.focus();
                return;
            }
            extendedCost.value = (requestedQuantity * unitCost.value).toFixed(2);
            subTotal = subTotal + parseFloat(extendedCost.value);
        }
    }
    document.purchaseOrderForm['subTotal'].value = subTotal.toFixed(2);

    for (var i = 0; i < document.purchaseOrderForm.poTaxType.length; i++)
    {
        if (document.purchaseOrderForm.poTaxType.options[i].selected == true)
        {

           stateWithtaxType = document.purchaseOrderForm.poTaxType.options[i].text;
           taxVal = stateWithtaxType.substring( ( stateWithtaxType.indexOf("-")+1 ), stateWithtaxType.length );

           break;
        }
    }

    if( taxVal == "Others" )
    {
        var newState = document.purchaseOrderForm.newPOState.value;
        var newTax = document.purchaseOrderForm.newPOTax.value;

        if( newTax == '' )
        {
            tax.value = '0.0';
        }
        else
        {
            tax.value = ( ( subTotal*parseFloat( newTax ) )/100 );
        }
    }
    else
    {
        if( taxVal == "Non Taxable")
        {
            tax.value = '0.0';
        }
        else
        {
            tax.value = ( ( subTotal*parseFloat( taxVal ) )/100 );
        }
    }

    total.value = ( parseFloat(subTotal) + parseFloat( freight.value) + parseFloat(misc.value) + parseFloat(tax.value)).toFixed(2);
    if( parseFloat(tradeDiscount.value) > parseFloat(total.value) )
    {
        errors = '';
        errorIndex.innerHTML = "<li> Trade Discount amount cannot be greater than Subtotal+Freight+Miscellaneous+Tax"
        errorIndex.focus();
        tradeDiscount.value = '0.0';
    }
    else
    {
        total.value = (parseFloat( total.value) - parseFloat(tradeDiscount.value)).toFixed(2);
    }
}

function setValue( element )
{
    prevPrice = element.value;
}

function packageTypeChanged( element, lineNo )
{
    errors='';
    var partNo = document.purchaseOrderForm['purchaseOrderLineItemList[' + lineNo + '].processStepId'].value
    var pakageType = document.purchaseOrderForm['purchaseOrderLineItemList[' + lineNo + '].packageType'].value

    if( partNo == '' )
    {
        element.value="";
        errors = "<li> Please select a Part Number before selecting the Package Type for LineItem "+  eval(lineNo+1)
        errorIndex.innerHTML = errors;
        errorIndex.focus();
        return;
    }
    if( pakageType == "Add_New_Package" )
    {
        newWindow = window.open ('purchaseOrders.do?action=loadPackageType','exportToFilePopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=350 height=350,resizable=no,left=375,top=180');
        newWindow.focus();
    }
}
function createOpenPO()
{
    var purchaseOrder_Id = document.purchaseOrderForm.purchaseOrder_Id.value;
    var searchType = document.purchaseOrderForm.searchType.value;

    if( purchaseOrder_Id == '-1' && searchType == 'Generate')
    {
        document.purchaseOrderForm.action = '<%=chipTracContext%>/purchaseOrders.do?action='+searchType;
    }
    else
    {
        document.purchaseOrderForm.action='<%=chipTracContext%>/searchPurchaseOrders.do?action='+searchType ;
    }
    document.purchaseOrderForm.submit();
}

function addNewPOTaxType(statename)
{
        var p1=document.getElementById("font-1");
        var p2=document.getElementById("font-2");
        var p3=document.getElementById("font-3");
        var p4=document.getElementById("font-4");
        p1.innerHTML = "";
        p2.innerHTML = "";
        p3.innerHTML = "";
        p4.innerHTML = "";

         <%--statename value -1 indicates new tax--%>
        if(statename.value == -1)
        {
             var htmltext1 = '<font class="NArialL">New State :</font>&nbsp;'
             var htmltext2 = '<input type="text" name="newPOState" size="18" maxlength="25" class="txfield" onblur="calculateTotals()" >'
             var htmltext3 = '<font class="NArialL">New Tax :</font>&nbsp;'
             var htmltext4 = '<input type="text" name="newPOTax" size="18" class="txfield" onkeypress="javascript:restrictCharacters(this,3,2)" maxlength="6" onkeyup="javascript:restrictAmt(this,3,2)"  onblur="calculateTotals()" >'

             p1.insertAdjacentHTML('BeforeEnd',htmltext1);
             p2.insertAdjacentHTML('BeforeEnd',htmltext2);
             p3.insertAdjacentHTML('BeforeEnd',htmltext3);
             p4.insertAdjacentHTML('BeforeEnd',htmltext4);
       }

      calculateTotals();
}

function taxFocus()
{
     document.purchaseOrderForm.newPOTax.focus();
}

function disableLineItem( lineItemNo, cancelElement )
{
   processName =  document.purchaseOrderForm['purchaseOrderLineItemList['+lineItemNo+'].processName'];
   packageType =  document.purchaseOrderForm['purchaseOrderLineItemList['+lineItemNo+'].packageType'];
   requestedDate = document.purchaseOrderForm['purchaseOrderLineItemList['+lineItemNo+'].requestedDate'];
   promisedDate = document.purchaseOrderForm['purchaseOrderLineItemList['+lineItemNo+'].promisedDate'];
   requestedQty = document.purchaseOrderForm['purchaseOrderLineItemList['+lineItemNo+'].requestedQuantity'];
   unitCost = document.purchaseOrderForm['purchaseOrderLineItemList['+lineItemNo+'].unitCost'];

   if( cancelElement.checked == true )
   {
         packageType.disabled = true;
         requestedDate.disabled = true;
         promisedDate.disabled = true;
         requestedQty.disabled = true;
         unitCost.disabled = true;
   }
   else
   {
        if( processName.options[ processName.selectedIndex ].text == '<%=ProcessTypes.assembly%>' )
        {
            packageType.disabled = false;
        }
         requestedDate.disabled = false;
         promisedDate.disabled = false;
         requestedQty.disabled = false;
         unitCost.disabled = false;
   }
}

function showHideNewShippingMethod()
{
    var form = document.purchaseOrderForm;
    var shippingMethodId = form.shippingMethodId.value;
    var shippingMethodIdCtrl = form.shippingMethodId;
    var newShippingMtdTable = document.getElementById( "newShippingMtdTable" ) ;
    var shipMethodCtrl = form.shipMethod;
    var shipAccountCtrl = form.shipAccount;

    if ( shippingMethodId == -2 )
    {
        newShippingMtdTable.style.display = "block"
        shipMethodCtrl.value = ""
    }
    else
    {
        newShippingMtdTable.style.display = "none"
        if ( shippingMethodId == -1 )
        {
            shipMethodCtrl.value = "";
        }
        else
        {
            shipMethodCtrl.value = shippingMethodIdCtrl.options[shippingMethodIdCtrl.selectedIndex].text
        }
    }
}

function showHideNewPayTerms()
{
    var form = document.purchaseOrderForm;
    var payTerms = form.payTerms.value;
    var payTermsLabel = document.getElementById( "payTermsLabel" ) ;
    var newPayTermsCtrl = form.newPayTerms;
    if ( payTerms == -2 )
    {
        payTermsLabel.style.display = "block"
        newPayTermsCtrl.style.display = "block"
    }
    else
    {
        payTermsLabel.style.display = "none"
        newPayTermsCtrl.style.display = "none"
    }
}

function getVendorPartNumber( indexID)
{
	var processStepId = 0;
	var vendorId = 0;
	var url = '';
	dateElement		= document.purchaseOrderForm['purchaseOrderLineItemList['+indexID+'].customerPartNumber'] ;
	vendorId		= document.purchaseOrderForm.vendor_id.value;
	processStepId	= document.purchaseOrderForm['purchaseOrderLineItemList['+indexID+'].processStepId'].value;

	if ( processStepId == '' )
	{
		errorIndex.innerHTML = "<li> Please select the Part Number</li>";
        errorIndex.focus();
        return;
	}

	url				= 'purchaseOrders.do?action=purchaseOrderLoadVendorPartNumbers&processStepId='+processStepId+'&vendorId='+vendorId+'&index='+ indexID;
	newWindow = window.open (url,'VENDORPARTNUMBER','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=350 height=350,resizable=no,left=375,top=180');
	newWindow.focus();
}

</script>

<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
    <TBODY>
    <TR>
        <td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
            <!-- Side Navigation start -->
            <%@include file="/jsp/finance/purchase_order_menu.jsp" %>
            <!-- end of the side navigations -->

        <TD bgcolor="#ffffff">
            <IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
        <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
        <TD valign="top" width="100%">
            <IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
            <BR>
<!-- from here your body starts -->
<html:form name="purchaseOrderForm"  type="com.scalar.chiptrack.finance.openpo.forms.PurchaseOrderForm" action="/purchaseOrders.do">
<%
    String jsMethod;
    String searchType = (String) request.getAttribute("searchType");
	if( searchType == null )
	{
		searchType = "OpenPOSearch";
	}
%>
                    <TABLE BORDER="0" WIDTH="50%" height="175%" >
                        <TR>
                            <TD WIDTH="100%" align = "">
                                <center><FONT styleClass="NArialL"><b>
                                <%
                                if( "Generate".equals(searchType ) )
                                {
                                %>
                                       Purchase Order Entry
                                <%
                                    }
                                    else if( "OpenPOSearch".equals(searchType ) )
                                    {
                                %>
                                        Purchase Order and Receipt Entry
                                <%
                                    }
                                     else if( "searchPendingPurchaseOrder".equals(searchType ) )
                                    {
                                %>
                                       Pending Purchase Order Entry
                                <%
                                    }
                                    else if( "searchChangePurchaseOrder".equals(searchType ) )
                                    {
                                %>
                                        Change Purchase Order Entry
                                <%
                                    }
                                %>

                                </b></FONT></center>
                            </TD>
                        </TR>
                    </TABLE>
                    <BR>
                    <TABLE BORDER="0" bordercolor='red' WIDTH="60%" CLASS="NArialL">
					<tr><td colspan=6>&nbsp;</td></tr>
					<tr><td colspan=6><chiptrack:info styleClass="NArialL"/></td></tr>
					<tr><td colspan=6><chiptrack:errors styleClass="NArialL"/></td></tr>					

                        <html:hidden name="purchaseOrderForm" property="purchaseOrder_Id"/>
                        <html:hidden name="purchaseOrderForm" property="vendor_id"/>
                        <html:hidden name="purchaseOrderForm" property="billingAddress_id"/>
                        <html:hidden name="purchaseOrderForm" property="shippingAddress_id"/>
                        <html:hidden name="purchaseOrderForm" property="revisionNo"/>
                        <TR>
                            <TD colspan="6"><FONT id="poErrors" color="red"></FONT></TD>
                        <TR>
                            <TD WIDTH="1%">&nbsp;</TD>
                            <TD WIDTH="24%">PO Number:</TD>
                            <TD WIDTH="24%" align = "left">
                                <nested:greaterThan property="purchaseOrder_Id" value="0">
                                    <bean:write  name="purchaseOrderForm" property="purchaseOrderNumber"/>
                                    <html:hidden name="purchaseOrderForm" property="purchaseOrderNumber"/>
                                </nested:greaterThan>
                                <nested:lessEqual property="purchaseOrder_Id" value="0">
                                    <nested:text property="purchaseOrderNumber" styleClass="txfield" size="10" maxlength="50"/>
                                </nested:lessEqual>                                
                            </TD>
                            <TD WIDTH="1%">&nbsp;</TD>
                            <TD WIDTH="25%">Type:&nbsp;</TD>
                            <TD WIDTH="25%">
                                <html:hidden property="poTypeLabel" />
                                <html:select property="poType" styleClass="txfield" disabled="true">
                                    <html:options collection = "purchaseOrderTypesList" property="label" labelProperty="value"/>
                                </html:select>
                            </TD>
                        </TR>
                        <TR>
                            <TD>&nbsp;</TD>
                            <TD>Vendor Name:&nbsp;</TD>
                            <TD>
                                <html:text name="purchaseOrderForm" property="vendorName" styleClass="txfield" size="21" maxlength="17" disabled="true" readonly="true"/>
                            </TD>
                            <TD>&nbsp;</TD>
                            <TD>PO Date:&nbsp;</TD>
                            <TD WIDTH="25%">
                                <html:text name="purchaseOrderForm" property="purchaseOrderDate" size ="11" styleClass="txField" maxlength="10" disabled="true"/>
                            </TD>
                        </TR>

                        <%
                            boolean disabled = false;
                        %>
                        <logic:equal name="searchType" value="searchPendingPurchaseOrder">
                            <%
                                disabled = true;
                            %>
                        </logic:equal>

                        <TR>
                                <TD>&nbsp;</TD>
                                <TD>Vendor Quote No:&nbsp;</TD>
                                <TD>
                            
                                <html:text name="purchaseOrderForm" property="vendorQuoteNumber" styleClass="txfield" size="21" maxlength="50" disabled="<%=disabled%>"/></td>
                                <TD>&nbsp;</TD>
                                <td WIDTH= "14%"><font class='NArialL'>Valid To : <font color=red>*</font></font></td>
					            <td WIDTH= "30%"><html:text styleClass='txfield' size='11' name='purchaseOrderForm' property="validToDate" disabled="<%=disabled%>"/>
						            <a href="javascript:openCalendar(document.purchaseOrderForm.validToDate)"><img onMouseOver="window.status='Click here to select date';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
					            </td>
                                <TD>&nbsp;</TD>
                        </TR>
                        <TR>
                                <TD WIDTH="1%">&nbsp;</TD>
                                <TD WIDTH="15%">
                                <logic:notEqual name="purchaseOrderForm" property="openPurchaseOrderNumber" value="">
                                Open PO Number:
                                </logic:notEqual>
                                &nbsp;</TD>
                                <TD WIDTH="17%">
                                    <bean:write name="purchaseOrderForm" property="openPurchaseOrderNumber"/>
                                    <html:hidden name="purchaseOrderForm" property="openPurchaseOrderNumber"/>
                                </TD>
                                <TD WIDTH="4%">&nbsp;</TD>
                                <TD WIDTH="14%" nowrap>&nbsp;</TD>
                                <TD WIDTH="30%">&nbsp;</TD>
                        </TR>

                        <tr>
                            <TD>&nbsp;</TD>
                            <td>
                                <font class='NArialL'><bean:message key="label.sales.salesOrder.ShippingMethod" /> : <font color=red>*</font></font>
                            </td>
                            <td>
                                <nested:hidden property="shipMethod"/>
                                <nested:select styleClass='txfield' property="shippingMethodId" onchange="showHideNewShippingMethod()" disabled="<%=disabled%>">
                                    <html:option value="-1">--- Select ---</html:option>
                                    <nested:optionsCollection property="shippingMethodsList" label="label" value="value"/>
                                    <html:option value="-2" >-- Add <bean:message key="label.sales.salesOrder.NewShippingMethod"/> --</html:option>
                                </nested:select>
                            </td>
                            <TD>&nbsp;</TD>
                            <td>
                                <font class='NArialL'>Pay Terms : <font color=red>*</font></font>
                            </td>
                            <td>
                                <nested:select styleClass='txfield' property="payTerms" onchange="showHideNewPayTerms()" disabled="<%=disabled%>">
                                    <html:option value="-1">--- Select ---</html:option>
                                    <nested:options property="payTermsList" />
                                    <html:option value="-2" >-- Add New Pay Terms --</html:option>
                                </nested:select>
                            </td>
                            <TD>&nbsp;</TD>
                        </tr>
                        <tr>
                            <TD>&nbsp;</TD>
                            <td colspan="2" class='NArialL'>
                                <table id="newShippingMtdTable">
                                    <tr class='NArialL'>
                                        <td>New Shipping Method:</td>
                                        <td>New Shipping Account:</td>
                                    </tr>
                                    <tr>
                                        <td align="center"><nested:text property="newShippingMethod" styleClass="txfield" size="18" maxlength="100"/></td>
                                        <td align="center"><nested:text property="newShippingAccount" styleClass="txfield" size="18" maxlength="50"/></td>
                                    </tr>
                                </table>
                            </td>
                            <TD>&nbsp;</TD>
                            <td>
                                <font class='NArialL' id="payTermsLabel"> New Pay Terms:<!-- <font color=red>*</font>--></font>
                            </td>
                            <td>
                                <nested:text property="newPayTerms" styleClass="txfield" size="18"/>
                            </td>
                            <TD>&nbsp;</TD>
                        </tr>
                        <TR>
                                <TD WIDTH="1%">&nbsp;</TD>
                                <TD WIDTH="15%" nowrap>&nbsp;</TD>
                                <TD WIDTH="17%"></TD>
                                <TD WIDTH="4%">&nbsp;</TD>
                                <TD WIDTH="14%" nowrap>Ship To Contact Person :&nbsp;</TD>
                                <TD WIDTH="30%">
                                    <html:select name="purchaseOrderForm" property="contactPerson" styleClass="txfield" onchange="javascript:loadShippingAddress();">
                                     <logic:present name="purchaseOrderForm" property="shippingContactPersonList">
                                        <html:optionsCollection property="shippingContactPersonList" name="purchaseOrderForm" label="label" value="value" />
                                     </logic:present>
                                    </html:select>
                                </TD>
                            </TR>
                        <TR>
                        <TR>
                                <TD WIDTH="1%">&nbsp;</TD>
                                <TD WIDTH="15%" nowrap>Bill To Address :&nbsp;</TD>
                                <TD WIDTH="17%">
                                    <html:textarea rows='11' cols="25" name="purchaseOrderForm" property="billingAddressAsString" styleClass='txfield' disabled="true"/>
                                </TD>
                                <TD WIDTH="4%">&nbsp;</TD>
                                <TD WIDTH="14%" nowrap>Ship To Address :&nbsp;</TD>
                                <TD WIDTH="30%">
                                    <html:textarea rows='11' cols="25" name="purchaseOrderForm" property="shippingAddressAsString" styleClass='txfield' disabled="true"/>
                                </TD>
                            </TR>
                        <TR>
                        <TR>
                             <TD WIDTH="1%">&nbsp;</TD>
                                <TD WIDTH="15%" nowrap>
								Comments:
                                </TD>
                                <TD WIDTH="17%" colspan="3">
                                <%if( "searchPendingPurchaseOrder".equalsIgnoreCase( searchType) ){%>
                                    <html:textarea rows='5' cols="60" name="purchaseOrderForm" property="comments" styleClass='txfield' disabled="true"/></TD>
                                 <%}else{%>
                                    <html:textarea rows='5' cols="60" name="purchaseOrderForm" property="comments" styleClass='txfield'   onkeydown="javascript:setTextAreaMaxLength(this,200)" onkeyup="javascript:setTextAreaMaxLength(this,200)"/></TD>
                                <%}%>
                                <td>&nbsp;</td>
                                <TD WIDTH="14%">&nbsp;</TD>
                        </TR>
                                <TD WIDTH="1%">&nbsp;</TD>
                                <TD WIDTH="15%" nowrap><logic:notEqual name="purchaseOrderForm" property="purchaseOrder_Id" value="-1">
                                    <font class="NArialL">Please Click here for <a class="leftsection" href="javascript:openAuditTrail(<bean:write name="purchaseOrderForm" property="purchaseOrder_Id"/>, '<bean:write name="purchaseOrderForm" property="purchaseOrderNumber"/>')" onmouseover="window.status='Click for Audit Trails';return true" onmouseout="window.status='';return true">
                                    Audit Trails</a>&nbsp;
                                    </font></logic:notEqual>
                                &nbsp;
                                </TD>
                                <TD WIDTH="17%">&nbsp;</TD>
                                <TD WIDTH="4%">&nbsp;</TD>
                                <TD WIDTH="14%"  class='NArialL'>&nbsp;</TD>
                                <TD WIDTH="30%">&nbsp;</TD>
                        </TR>
                    </TABLE>

        <table border="0" align = "left" width ="100%" >
         <TR>
                <TD WIDTH="100%">
                    <TABLE BORDER="0" WIDTH="100%" CLASS="NArialL">
                        <TR>
                            <TD WIDTH = "100%" COLSPAN="11" class="NArialL" style="color:red" id='errorIndex'></TD>
                        </TR>
                        <tr>
                            <TD WIDTH = "100%" COLSPAN="11">&nbsp;</TD>
                        </tr>
                        <logic:equal name="searchType" value="searchChangePurchaseOrder">
                            <TR>
                                <td colspan='12'>
                                    <font class="NArialS" color='blue'><b>
                                    <li>&nbsp;RECEIVED or CLOSED LineItems cannot be modified and cancelled.
                                    <br>
                                    <li>&nbsp;Disabled rows indicate CANCELLED LineItems and they cannot be changed.
                                    <br>
                                    </b></font>
                                </td>
                                <TD COLSPAN="11" colspan='3' align='right' valign='bottom'>&nbsp;
                                </td>
                            </tr>
                        </logic:equal>
                        <tr>
                            <td colspan="12">&nbsp;</td>
                            <TD COLSPAN="11" colspan='3' align='right' valign='bottom'>
                                <A href="javascript:openReasonCodes();"onmouseover="window.status='Click for Reason Codes';return true" onmouseout="window.status='';return true" >ReasonCodes Description</A>
                            </td>
                        </tr>
                        <TR>
                            <TD WIDTH="4%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER">&nbsp;<FONT COLOR="white">Line Item</FONT>
                            </TD>
                            <TD WIDTH="10%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Process Name&nbsp;*</FONT>
                            </TD>
                            <TD WIDTH="10%" HEIGHT="26" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Part Number&nbsp;*</FONT>
                            </TD>
							<TD WIDTH="10%" HEIGHT="26" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Vendor Part Number</FONT>
                            </TD>
                            <TD WIDTH="16%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Description</FONT>
                            </TD>

                            <TD WIDTH="10%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Package Type</FONT>
                            </TD>
                            <TD WIDTH="10%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Requested Date&nbsp;*</FONT>
                            </TD>
                            <TD WIDTH="10%" HEIGHT="16" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Promised Date</FONT>
                            </TD>
                            <TD WIDTH="10%" HEIGHT="16" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Requested Quantity&nbsp;*</FONT>
                            </TD>
                            <TD WIDTH="10%" HEIGHT="16" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Previous Received Quantity</FONT>
                            </TD>
                            <TD WIDTH="10%" HEIGHT="16" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Received Quantity</FONT>
                            </TD>
                            <TD HEIGHT="16" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Unit Cost($)</FONT>
                            </TD>
                            <TD WIDTH="10%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Extended Cost($)</FONT>
                            </TD>
                            <TD WIDTH="10%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Status</FONT>
                            </TD>
                            <TD WIDTH="10%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
                                <P ALIGN="CENTER"><FONT COLOR="white">Cancel</FONT>
                            </TD>
                            <TD width="20%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">
                                <table width="100%" border=0>
                                    <tr><td colspan=3 class="NArialL" align=center><font color="#FFFFFF">Holds</font></td></tr>
                                    <font size="-3">
                                    <TR>
                                        <td  width="40%" align=center class="NArialL"><font color="#FFFFFF">Fin</font></td>
                                        <td  width="20%">&nbsp;</td>
                                        <td  width="40%" align=center class="NArialL"><font color="#FFFFFF">Ops</font></td>
                                     </TR>
                                      </font>
                                </table></font></font>
                             </TD>
                        </TR>
                        <nested:iterate id="purchaseOrderlineItem" property="purchaseOrderLineItemList" type="com.scalar.chiptrack.finance.openpo.PurchaseOrderLineItem" indexId="lineItemIndex">
                        <TR>
                            <TD WIDTH="4%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
                                <P ALIGN="CENTER"><nested:write property="purchaseOrderLineItemNumber"/>&nbsp;
                            </TD><nested:hidden property="purchaseOrderLineItem_Id"/>
                            <nested:hidden property="purchaseOrderLineItemNumber"/>
                            <input type="hidden" name="lineItem">
                            <nested:define id="vendorPartNoList" property="partNumbersList" type="java.util.ArrayList"/>
							<nested:define id="vendorPartDescList" property="partDescriptionList" type="java.util.ArrayList"/>
                            <%
                                if( purchaseOrderlineItem.getPurchaseOrderLineItem_Id() == -1 )
                                {
                            %>
                                <TD WIDTH="10%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
                                    <CENTER>
                                        <P>
                                            <% jsMethod = "javascript:loadPartNumbers('" + i + "')" ; %>
                                            <nested:select property="processName" styleClass="txfield" onchange="<%=jsMethod%>">
                                               <html:option value="" >----- Select -----</html:option>
                                                <html:options collection="processNameList" property="value" labelProperty="label"/>&nbsp;
                                            </nested:select>
                                        </p>
                                        </center>
                                </td>
                                <TD WIDTH="10%" BGCOLOR="#DEE1E2" ALIGN="CENTER">
                                        <% jsMethod = "javascript:loadComments(" + i + ")" ; %>
                                        <nested:select property="processStepId" styleClass="txfield" onchange='<%=jsMethod%>'>
                                           <html:option value="" >----- Select -----</html:option>
                                           <html:options collection="vendorPartNoList" property="value" labelProperty="label"/>&nbsp;
                                        </nested:select>
                                    <nested:hidden property="partNumber"/>
                                </TD>
								<TD WIDTH="16%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
                                <CENTER>
                                <P>
                                    <nested:text property="customerPartNumber"  size ="10" styleClass="txField"/>&nbsp;
									<a href="javascript:getVendorPartNumber(<%=i%>)"><img onMouseOver="window.status='Click here to select vendor part number';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/glass.jpg" height=20 width=20></a>
                                </p>
                                </CENTER>
								</TD>
                                <TD WIDTH="16%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
                                    <CENTER>
                                    <P>
                                        <nested:textarea property="description" styleClass="txField" onkeydown="javascript:setTextAreaMaxLength(this,200)" onkeyup="javascript:setTextAreaMaxLength(this,200)"/>
                                    </CENTER>
                                </TD>
                             <%
                                }
                                if( purchaseOrderlineItem.getPurchaseOrderLineItem_Id() != -1 )
                                {
                             %>
                                <TD WIDTH="10%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
                                    <CENTER>
                                        <P>
                                            <nested:select property="processName" styleClass="txfield" disabled="true">
                                               <html:option value="" >----- Select -----</html:option>
                                                <html:options collection="processNameList" property="value" labelProperty="label"/>&nbsp;
                                            </nested:select>
                                        </p>
                                    </center>
                                </TD>
                            <TD WIDTH="10%" BGCOLOR="#DEE1E2" ALIGN="CENTER">
                                    <nested:select property="processStepId" styleClass="txfield" disabled="true">
                                       <html:option value="" >----- Select -----</html:option>
                                       <html:options collection="vendorPartNoList" property="value" labelProperty="label"/>&nbsp;
                                    </nested:select>
                                <nested:hidden property="partNumber"/>
                            </TD>
							<TD WIDTH="10%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
                                <CENTER>
                                <P>
                                    <nested:text property="customerPartNumber" styleClass="txField" disabled="true"/>
                                </p>
                                </CENTER>
                            </TD>
                            <TD WIDTH="16%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
                                <CENTER>
                                <P>
                                    <nested:textarea property="description" styleClass="txField" disabled="true"/>
                                </p>
                                </CENTER>
                            </TD>
                            <%
                                }
                            %>
                            <script language='javascript'>
                            lineItemsComments.push( new Array() );
                            <%
                                //replace the "vendorPartNoList" with the arrayList variable holding the comments for this lineItem
                                if( vendorPartDescList != null && vendorPartDescList.size() > 0 )
                                {
                                    for( int j = 0; j < vendorPartDescList.size(); j++ )
                                    {
										out.print("lineItemsComments["+i+"].push(\""+((LabelValueBean)vendorPartDescList.get(j)).getLabel()+"\");\n");
                                    }
                                }
                            %>
                            </script>
                            <TD WIDTH="16%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
                                <CENTER>
                                <P>
                                <%
                                    String processName = purchaseOrderlineItem.getProcessName();
                                    if( processName != null && ProcessTypes.assembly.equalsIgnoreCase(processName) &&
                                            !("searchPendingPurchaseOrder".equals(searchType)) &&
                                            !purchaseOrderlineItem.getCancel() &&
                                            !Constants.PURCHASE_ORDER_STATUS_RECEIVED.equalsIgnoreCase(purchaseOrderlineItem.getStatus()) &&
                                            !Constants.PURCHASE_ORDER_STATUS_CLOSED.equalsIgnoreCase(purchaseOrderlineItem.getStatus()) )
                                    {
                                        jsMethod = "packageTypeChanged( this,"+i+")";
                                %>
                                <nested:select property="packageType" styleClass="txfield" onchange="<%=jsMethod%>">
                                   <html:option value="" >Select</html:option>
                                    <html:options collection="packageTypeList" property="label" labelProperty="value"/>&nbsp;
                                    <html:option value="Add_New_Package" >--AddNew--</html:option>
                                </nested:select>
                                <%
                                    }
                                    else
                                    {
                                        if ( purchaseOrderlineItem.getCancel() )
                                        {
                                %>
                                            <nested:select property="packageType" styleClass="txfield" disabled="true">
                                               <html:option value="" >Select</html:option>
                                                <html:options collection="packageTypeList" property="label" labelProperty="value"/>&nbsp;
                                            </nested:select>
                                <%
                                        }
                                        else
                                        {
                                %>
                                            <nested:text property="packageType" styleClass="txfield" size ="5" disabled="true"/>
                                <%
                                        }
                                    }
                                %>
                                </CENTER>
                            </TD>

                            <TD WIDTH="10%" ALIGN="LEFT" BGCOLOR="#DEE1E2" nowrap>
                                <P>
                                <%
                                    if( "searchPendingPurchaseOrder".equalsIgnoreCase(searchType) || purchaseOrderlineItem.getCancel() ||
                                            Constants.PURCHASE_ORDER_STATUS_RECEIVED.equalsIgnoreCase(purchaseOrderlineItem.getStatus()) ||
                                            Constants.PURCHASE_ORDER_STATUS_CLOSED.equalsIgnoreCase(purchaseOrderlineItem.getStatus()) )
                                    {
                                %>
                                        <nested:text name="purchaseOrderForm" property="requestedDate" size ="11" styleClass="txField" maxlength="10" disabled="true"/>
                                <%
                                    }
                                    else
                                    {
                                %>
                                        <nested:text name="purchaseOrderForm" property="requestedDate" size ="11" styleClass="txField" maxlength="10"/>
                                <%
                                    }
                                    if( !Constants.PURCHASE_ORDER_STATUS_RECEIVED.equalsIgnoreCase(purchaseOrderlineItem.getStatus()) &&
                                        !Constants.PURCHASE_ORDER_STATUS_CLOSED.equalsIgnoreCase(purchaseOrderlineItem.getStatus()) &&
                                        !Constants.PURCHASE_ORDER_STATUS_CANCELLED.equalsIgnoreCase(purchaseOrderlineItem.getStatus()) )
                                    {
                                %>
                                        <a href="javascript:openCalendar(document.purchaseOrderForm['purchaseOrderLineItemList[<%=i%>].requestedDate'])"><img onMouseOver="window.status='Click here to select date';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
                                    <%
                                    }
                                    %>
                            </TD>

                            <TD WIDTH="10%" ALIGN="LEFT" BGCOLOR="#DEE1E2" nowrap>
                                <P>
                                <%
                                    if( "searchPendingPurchaseOrder".equalsIgnoreCase(searchType) || purchaseOrderlineItem.getCancel() ||
                                            Constants.PURCHASE_ORDER_STATUS_RECEIVED.equalsIgnoreCase(purchaseOrderlineItem.getStatus()) ||
                                            Constants.PURCHASE_ORDER_STATUS_CLOSED.equalsIgnoreCase(purchaseOrderlineItem.getStatus()) )
                                    {
                                %>
                                    <nested:text name="purchaseOrderForm" property="promisedDate" size ="11" styleClass="txField" maxlength="10" disabled="true"/>
                                <%
                                    }
                                    else
                                    {
                                %>
                                    <nested:text name="purchaseOrderForm" property="promisedDate" size ="11" styleClass="txField" maxlength="10"/>
                                <%
                                    }
                                    if( !Constants.PURCHASE_ORDER_STATUS_RECEIVED.equalsIgnoreCase(purchaseOrderlineItem.getStatus()) &&
                                        !Constants.PURCHASE_ORDER_STATUS_CLOSED.equalsIgnoreCase(purchaseOrderlineItem.getStatus())&&
                                        !Constants.PURCHASE_ORDER_STATUS_CANCELLED.equalsIgnoreCase(purchaseOrderlineItem.getStatus())  )
                                    {
                                %>
                                    <a href="javascript:openCalendar(document.purchaseOrderForm['purchaseOrderLineItemList[<%=i%>].promisedDate'])"><img onMouseOver="window.status='Click here to select date';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
                                <%
                                    }
                                %>
                               </TD>

                            <TD WIDTH="10%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
                                <CENTER>
                                <P>
                                <%
                                    if( "searchPendingPurchaseOrder".equalsIgnoreCase(searchType) || purchaseOrderlineItem.getCancel() ||
                                            Constants.PURCHASE_ORDER_STATUS_RECEIVED.equalsIgnoreCase(purchaseOrderlineItem.getStatus()) ||
                                            Constants.PURCHASE_ORDER_STATUS_CLOSED.equalsIgnoreCase(purchaseOrderlineItem.getStatus()) )
                                    {
                                %>
                                        <nested:text property="requestedQuantity" styleClass="valuetxfield" size="10" maxlength="6" disabled="true"/>
                                <%
                                    }
                                    else
                                    {
                                %>
                                        <nested:text property="requestedQuantity" styleClass="valuetxfield" size="10" maxlength="6" onblur='calculateTotals()'  onkeydown="javascript:setValue(this)"  onkeypress="javascript:allowInteger()"/>
                                <%
                                    }
                                %>
                                </CENTER>
                            </TD>
                            <TD WIDTH="10%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
                                <CENTER>
                                <P>
                                <nested:text property="previouslyShipppedQty" styleClass="valuetxfield" size="10" disabled="true"/>
                                </CENTER>
                            </TD>

                            <TD WIDTH="10%" ALIGN="left" BGCOLOR="#DEE1E2" nowrap>
                                <P>
                                <%
                                    jsMethod = "javascript:disableHolds("+i+")";
                                %>
                                <nested:text property="shippedQty" styleClass="valuetxfield" size="10"  disabled="true" onchange='<%=jsMethod%>'/>

                                <%
                                jsMethod = "javascript:lotDateEntry('" +  purchaseOrderlineItem.getPurchaseOrderLineItemNumber()   + "')" ;
                                %>
                                <logic:notEqual name="purchaseOrderForm" property="openPurchaseOrder_Id" value="-1">
                                <%
                                    if( purchaseOrderlineItem.getPurchaseOrderLineItem_Id() == -1 )
                                    {
                                %>
                                        <a href="<%= jsMethod %>" onmouseover="window.status='Click here To add Lot Information';return true" onmouseout="window.status='';return true">
                                                <IMG SRC="<%=chipTracContext%>/jsp/includes/images/arrow.gif" WIDTH="14" HEIGHT="15" ALIGN="center" BORDER="0"></a>
                                <%
                                    }
                                %>
                                </logic:notEqual>
                            </TD>

                            <TD ALIGN="CENTER" BGCOLOR="#DEE1E2">
                                <CENTER>
                                <%
                                    if( "searchPendingPurchaseOrder".equalsIgnoreCase(searchType) || purchaseOrderlineItem.getCancel() ||
                                            Constants.PURCHASE_ORDER_STATUS_RECEIVED.equalsIgnoreCase(purchaseOrderlineItem.getStatus()) ||
                                            Constants.PURCHASE_ORDER_STATUS_CLOSED.equalsIgnoreCase(purchaseOrderlineItem.getStatus()) )
                                    {
                                %>
                                        <P><nested:text property="unitCost" styleClass="valuetxfield" size="10"  disabled="true"/>
                                <%
                                    }
                                    else
                                    {
                                %>
                                        <P><nested:text property="unitCost" styleClass="valuetxfield" size="10"  onblur='calculateTotals()' onkeypress="javascript:restrictCharacters(this,7,2)"  onkeydown="javascript:setValue(this)" onkeyup="javascript:restrictAmt(this,7,2)"/>
                                <%
                                    }
                                %>
                                </CENTER>
                            </TD>

                            <TD WIDTH="10%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
                                <CENTER>
                                <P><nested:text property="extendedCost" styleClass="valuetxfield" size="10" disabled='true'/>
                                </CENTER>
                            </TD>

                            <TD WIDTH="10%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
                                <CENTER>
                                <P><nested:text property="status" styleClass="txfield" size="10" disabled="true"/>
                                </CENTER>
                            </TD>
                            <TD  WIDTH="10%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
                                <CENTER>
                                <P>
                                <%
                                    if(     purchaseOrderlineItem.getPurchaseOrderLineItem_Id() == -1 ||
                                            "searchPendingPurchaseOrder".equals(searchType) ||
                                            Constants.PURCHASE_ORDER_STATUS_RECEIVED.equals( purchaseOrderlineItem.getStatus()) ||
                                            Constants.PURCHASE_ORDER_STATUS_CLOSED.equals( purchaseOrderlineItem.getStatus()) ||
                                            Constants.PURCHASE_ORDER_STATUS_CANCELLED.equals( purchaseOrderlineItem.getStatus()) )
                                    {
                                %>
                                    <nested:checkbox property="cancel" styleClass="txfield" disabled="true"/>
                                <%
                                    }
                                    else
                                    {
                                        jsMethod = "disableLineItem("+i+", this)";
                                %>
                                    <nested:checkbox property="cancel" styleClass="txfield" onclick="<%=jsMethod%>"/>
                                <%
                                    }
                                %>
                                </CENTER>
                            </TD>
                            <TD ALIGN="left" BGCOLOR="#DEE1E2" nowrap>
                             <logic:notEqual name="purchaseOrderForm" property="openPurchaseOrder_Id" value="-1">
                             <%
                                 if( searchType.equalsIgnoreCase("OpenPOSearch"))
                                 {
                             %>
                                    <logic:equal  name="purchaseOrderlineItem" property="shippedQty" value="0">
                                        <nested:select property="financeHold" styleClass="txfield">
                                            <html:options collection="financeReasonCodes" property="value" labelProperty="label" />
                                        </nested:select>
                                        &nbsp;
                                        <nested:select property="operationsHold" styleClass="txfield">
                                            <html:options collection="opsReasonCodes" property="value" labelProperty="label" />
                                        </nested:select>
                                    </logic:equal>
                                    <logic:notEqual  name="purchaseOrderlineItem" property="shippedQty" value="0">
                                        <nested:select property="financeHold" styleClass="txfield" disabled="true">
                                            <html:options collection="financeReasonCodes" property="value" labelProperty="label" />
                                        </nested:select>
                                        &nbsp;
                                        <nested:select property="operationsHold" styleClass="txfield" disabled="true">
                                            <html:options collection="opsReasonCodes" property="value" labelProperty="label" />
                                        </nested:select>
                                    </logic:notEqual>
                            <%
                                 }
                            %>
                                <logic:equal name="searchType" value="searchChangePurchaseOrder">
                                        <nested:select property="financeHold" styleClass="txfield" disabled="true">
                                            <html:options collection="financeReasonCodes" property="value" labelProperty="label" />
                                        </nested:select>
                                        &nbsp;
                                        <nested:select property="operationsHold" styleClass="txfield" disabled="true">
                                            <html:options collection="opsReasonCodes" property="value" labelProperty="label" />
                                        </nested:select>
                                </logic:equal>
                                <logic:equal name="searchType" value="searchPendingPurchaseOrder">
                                <%
                                    if ( Constants.PURCHASE_ORDER_STATUS_NEW.equalsIgnoreCase(purchaseOrderlineItem.getStatus()) || Constants.PURCHASE_ORDER_STATUS_RELEASED.equalsIgnoreCase(purchaseOrderlineItem.getStatus()))
                                    {
                                %>
                                        <nested:select property="financeHold" styleClass="txfield">
                                            <html:options collection="financeReasonCodes" property="value" labelProperty="label" />
                                        </nested:select>
                                        &nbsp;
                                        <nested:select property="operationsHold" styleClass="txfield">
                                            <html:options collection="opsReasonCodes" property="value" labelProperty="label" />
                                        </nested:select>
                                <%
                                    }
                                    else
                                    {
                                %>
                                        <nested:select property="financeHold" styleClass="txfield" disabled="true">
                                            <html:options collection="financeReasonCodes" property="value" labelProperty="label" />
                                        </nested:select>
                                        &nbsp;
                                        <nested:select property="operationsHold" styleClass="txfield"  disabled="true">
                                            <html:options collection="opsReasonCodes" property="value" labelProperty="label" />
                                        </nested:select>
                                <%
                                    }
                                %>
                                </logic:equal>
                            </logic:notEqual>
                            <logic:equal name="purchaseOrderForm" property="openPurchaseOrder_Id" value="-1">
                                <logic:equal name="searchType" value="searchPendingPurchaseOrder">
                                    <nested:select property="financeHold" styleClass="txfield">
                                        <html:options collection="financeReasonCodes" property="value" labelProperty="label" />
                                    </nested:select>
                                    &nbsp;
                                    <nested:select property="operationsHold" styleClass="txfield">
                                        <html:options collection="opsReasonCodes" property="value" labelProperty="label" />
                                    </nested:select>
                                </logic:equal>
                                <logic:notEqual name="searchType" value="searchPendingPurchaseOrder">
                                    <nested:select property="financeHold" styleClass="txfield" disabled="true">
                                        <html:options collection="financeReasonCodes" property="value" labelProperty="label" />
                                    </nested:select>
                                    &nbsp;
                                    <nested:select property="operationsHold" styleClass="txfield" disabled="true">
                                        <html:options collection="opsReasonCodes" property="value" labelProperty="label" />
                                    </nested:select>
                                </logic:notEqual>
                            </logic:equal>
                            </TD>
                        </TR>
                        <% i++;%>
                        </nested:iterate>
                        <TR>
                            <TD width="20%" colspan="8">&nbsp;</TD>
                            <TD WIDTH="20%">&nbsp;</TD>
                            <TD WIDTH="12%">&nbsp;</TD>
                            <TD WIDTH="26%">&nbsp;</TD>
                            <TD WIDTH="8%">&nbsp;</TD>
                        </TR>
                        <TR>
                                <TD WIDTH="20%" colspan="10">&nbsp;</TD>
                                <TD WIDTH="26%" ALIGN="RIGHT">Sub Total:&nbsp;$</TD>
                                <TD WIDTH="8%">
                                    <nested:text property="subTotal" styleClass="valuetxfield" size="10" disabled='true'/>
                                <TD WIDTH="14%">&nbsp;</TD>
                                <TD WIDTH="14%">&nbsp;</TD>
                        </TR>
                        <TR>
                            <TD width="20%" colspan="3"> &nbsp; </TD>
                            <TD width="20%" > PO Tax State </TD>
                            <TD width="20%" colspan="6">
                            <% if ("searchPendingPurchaseOrder".equalsIgnoreCase( searchType ) ){%>
                                   <html:select name="purchaseOrderForm" property="poTaxType" styleClass="txfield" disabled="true">
                                        <html:option value="0" >Non Taxable</html:option>
                                        <html:options collection="poTaxes" property="value" labelProperty="label" />
                                        <html:option value="-1">Others</html:option>
                                    </html:select>
                              <%}else{%>
                                  <html:select name="purchaseOrderForm" property="poTaxType" styleClass="txfield" onchange="javascript:addNewPOTaxType(this);">
                                        <html:option value="0" >Non Taxable</html:option>
                                        <html:options collection="poTaxes" property="value" labelProperty="label" />
                                        <html:option value="-1">Others</html:option>
                                    </html:select>
                              <%}%>
                            </TD>
                            <TD WIDTH="26%" ALIGN="RIGHT">Freight:&nbsp;$</TD>
                            <TD WIDTH="8%">
                          <% if ("searchPendingPurchaseOrder".equalsIgnoreCase( searchType ) ){%>
                                <nested:text property="freight" styleClass="valuetxfield" size="10" disabled="true"/></TD>
                           <%}else{%>
                                <nested:text property="freight" styleClass="valuetxfield" size="10" onblur='calculateTotals()' onkeydown="javascript:setValue(this)" onkeypress="javascript:restrictCharacters(this,7,2)" onkeyup="javascript:restrictAmt(this,7,2)"/></TD>
                            <%}%>
                            <TD WIDTH="14%">&nbsp;</TD>
                            <TD WIDTH="14%">&nbsp;</TD>
                        </TR>
                        <TR>
                            <TD width="20%" colspan="3"> &nbsp; </TD>
                            <TD width="20%" ><font class="NArialL"><FONT id="font-1"></FONT></font></TD>
                            <TD width="20%" colspan="6"><font class="NArialL"><FONT id="font-2"></FONT></font></TD>
                            <TD WIDTH="26%" ALIGN="RIGHT" nowrap>Trade Discount&nbsp;$</TD>
                            <TD WIDTH="8%">
                         <% if ("searchPendingPurchaseOrder".equalsIgnoreCase( searchType ) ){%>
                                <nested:text property="tradeDiscount" styleClass="valuetxfield" size="10" disabled="true"/></TD>
                         <%}else{%>
                                <nested:text property="tradeDiscount" styleClass="valuetxfield" size="10"  onblur='calculateTotals()'  onkeydown="javascript:setValue(this)" onkeypress="javascript:restrictCharacters(this,7,2)" onkeyup="javascript:restrictAmt(this,7,2)"/></TD>
                         <%}%>

                            <TD WIDTH="14%">&nbsp;</TD>
                            <TD WIDTH="14%">&nbsp;</TD>
                        </TR>
                        <TR>
                            <TD width="20%" colspan="3"> &nbsp; </TD>
                            <TD width="20%" ><font class="NArialL"><FONT id="font-3"></FONT></font></TD>
                            <TD width="20%" colspan="6"><font class="NArialL"><FONT id="font-4"></FONT></font></TD>
                            <TD WIDTH="26%" ALIGN="RIGHT">Miscellaneous:&nbsp;$</TD>
                            <TD WIDTH="8%">
                         <% if ("searchPendingPurchaseOrder".equalsIgnoreCase( searchType ) ){%>
                                <nested:text property="miscellaneous" styleClass="valuetxfield" size="10" disabled="true"/></TD>
                         <%}else{%>
                                <nested:text property="miscellaneous" styleClass="valuetxfield" size="10" onblur='calculateTotals()' onkeypress="javascript:restrictCharacters(this,7,2)"  onkeydown="javascript:setValue(this)" onkeyup="javascript:restrictAmt(this,7,2)"/></TD>
                         <%}%>
                            <TD WIDTH="14%">&nbsp;</TD>
                            <TD WIDTH="14%">&nbsp;</TD>
                        </TR>
                        <TR>
                            <TD width="20%" colspan="10">&nbsp;</TD>
                            <TD WIDTH="26%" ALIGN="RIGHT">Tax:&nbsp;$</TD>
                            <TD WIDTH="8%">
                                <nested:text property="tax" styleClass="valuetxfield" size="10" disabled="true" /></TD>
                            <TD WIDTH="14%">&nbsp;
                            <TD WIDTH="14%">&nbsp;</TD>
                        </TR>
                        <TR>
                            <TD width="20%" colspan="10">&nbsp;</TD>
                            <TD WIDTH="26%" ALIGN="RIGHT">Order Total:&nbsp;$</TD>
                            <TD WIDTH="8%"><nested:text property="total" styleClass="valuetxfield" size="10"  disabled='true'/></TD>
                            <TD WIDTH="14%">&nbsp;</TD>
                            <TD WIDTH="14%">&nbsp;</TD>
                        </TR>
                        <TR>
                            <TD width="20%" colspan="10">&nbsp;</TD>
                            <TD WIDTH="20%">&nbsp;</TD>
                            <TD WIDTH="12%">&nbsp;</TD>
                            <TD WIDTH="26%">&nbsp;</TD>
                            <TD WIDTH="8%">&nbsp;</TD>
                    </TR>
                    <TR>
                        <TD width="20%" colspan="8">&nbsp;</TD>
                        <TD WIDTH="26%">
                         <logic:notEqual name="searchType" value="searchPendingPurchaseOrder">
                            <chiptrack:restrictedLink functionality="<%=functionalityString%>"
                                action="<%=User.USER_ACTION_MODIFY%>"href="javascript:addLineItem()" onmouseover="window.status='Click to add a new Line Item';return true" onmouseout="window.status='';return true">
                                <IMG SRC="<%=chipTracContext%>/jsp/includes/images/addmore.gif" title="Click here to Add Line Item"ALIGN="BOTTOM" BORDER="0" >
                            </chiptrack:restrictedLink>
                        </logic:notEqual>
                        </TD>
                        <TD WIDTH="8%">&nbsp;
                        </TD>
                        <TD WIDTH="12%">&nbsp;</TD>
                        <TD WIDTH="14%">&nbsp;</TD>
                    </TR><!-- added submit button-->
            <TR align = "center" border="0">
            <TD bgColor="" align="center" colspan = '7'>
                <A href="javascript:confirmPO()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17" onmouseover="window.status='Click to Create PO';return true" onmouseout="window.status='';return true" title="Click here to Save Purchase Order"></A>&nbsp;&nbsp;&nbsp;
                <A href="javascript:document.purchaseOrderForm.reset()" onMouseOver="window.status='Click to Reset the PO Information';return true" onMouseOut="window.status='';return true" title="Click here to Reset Process Information"><IMG border=0 src="<%=chipTracContext%>/jsp/includes/images/reset.gif"></a>&nbsp;&nbsp;&nbsp;
                <A href="javascript:createOpenPO();" class="leftsection" onmouseover="window.status='';return true" onmouseout="window.status='';return true"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/cancel.gif" title="" ></A>
            </TD>
            <td colspan='8'>&nbsp;</td>
         </TR>

                    </TABLE>
                    <BR>
                </TD>
           </TR>
          </TABLE>
<input type="hidden" name="searchType" value="<%=request.getAttribute("searchType")%>">
</html:form>
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
<logic:present name="purchaseOrderForm" property="shippingContactPersonList">
<SCRIPT language="javascript">
loadShippingAddress();
</SCRIPT>
</logic:present>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</HTML>
